<?php namespace App\Repositories\Item;

use App\Repositories\Eloquent\Item\Entity\ItemEntity;

interface ItemRepositoryInterface
{
    /**
     * 查询消息
     *
     * @param $id
     *
     * @return \Illuminate\Database\Eloquent\Collection|\App\Models\Item|\App\Models\Item[]
     */
    public function show($id);

    /**
     * 查询消息，如果查询不到，这抛出异常
     *
     * @param $id
     *
     * @return \Illuminate\Database\Eloquent\Collection|\App\Models\Item|\App\Models\Item[]
     * @throws ItemException
     */
    public function showWitThrow($id);

    /**
     * 发布者的信息列表
     *
     * @param $publisher_uid
     * @param $per_page
     *
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
     */
    public function getPublisherItems($publisher_uid, $per_page);

    /**
     * 新增信息
     *
     * @param ItemEntity $entity
     *
     * @return Item
     * @throws OtherException
     */
    public function store(ItemEntity $entity);

    /**
     * 修改信息
     *
     * @param            $id
     * @param ItemEntity $entity
     *
     * @return Item
     * @throws OtherException
     */
    public function update($id, ItemEntity $entity);

    /**
     * 发布者结束掉信息
     *
     * @param $id
     * @param $user_id
     *
     * @return Item|Item[]|\Illuminate\Database\Eloquent\Collection
     */
    public function publisherFinish($id, $user_id);

    /**
     * 最新有效信息
     *
     * @param $per_page
     *
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
     */
    public function latestValidItems($per_page);
}
